package avicit.bdp.dgs.qa.service.algo.raw.data.pcm.checker;

import avicit.bdp.dgs.qa.service.algo.raw.data.pcm.entity.PcmHeadInfo;
import avicit.bdp.dgs.qa.service.algo.raw.data.pcm.entity.PcmStreamInfo;
import avicit.bdp.dgs.qa.service.algo.raw.data.pcm.utils.ReadInfConfigUtils;

import java.io.IOException;
import java.util.List;
import java.util.Map;

/**
 * @金航数码科技有限责任公司
 * @作者：developer
 * @邮箱：developer@avic-digital.com
 * @创建时间： 2023-11-01
 * @类说明：PCMConfigReader
 * @修改记录：
 * @注意事项：
 * @主要功能：
 */
public class PCMConfigReader {
    private ReadInfConfigUtils readInfConfigUtils;

    private Map<String, Object> configInfo;

    public PCMConfigReader(String configPath, Map<String, Object> inputParamsMap) throws IOException {
        this.readInfConfigUtils = new ReadInfConfigUtils(configPath, inputParamsMap);
        this.configInfo = readInfConfigUtils.getAllConfigInfo();
    }

    public PcmHeadInfo getPcmHeadInfo() {
        return (PcmHeadInfo) configInfo.get("headInfo");
    }

    public PcmStreamInfo getPcmStreamInfo(int index) {
        List<PcmStreamInfo> streamInfoList = (List<PcmStreamInfo>) configInfo.get("pcmStream");
        if (index >= streamInfoList.size() || index < 0) {
            return null;
        }
        return streamInfoList.get(index);
    }
}
